<?php
$content = 'company/latest.php';
$post_title = 'Your last posts';
require_once TMP_SELL_PATH;
?>
<?php
$rowsPerPage = isset($_GET['num']) ? $_GET['num'] : '12';
$comid = $user_ck['user_id'];
$sql = "SELECT t1.*, t1.top_view, t3.price, t3.pid, t2.images, t2.thumbnail FROM tblproduct AS t1
                        LEFT JOIN tblimage AS t2 ON t1.id=t2.product_id
                        INNER JOIN tblproduct_in_pharmacy AS t3 ON t1.id=t3.product_id
                        WHERE  t1.status = 1 AND t1.owner = '" . $comid . "' GROUP BY t1.id ORDER BY t1.id DESC";
$result = mysql_query(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);
$i = 1;
$border = "";
if (dbNumRows($result) > 0) {
    while ($data = mysql_fetch_assoc($result)) {
        /* get price */
        $price = mysql_query("SELECT price,regular_price FROM tblproduct_in_pharmacy WHERE product_id=" . $data['id'] . " ORDER BY price ASC LIMIT 0,1");
        $myprice = mysql_fetch_assoc($price);
        $price1 = mysql_query("SELECT price,regular_price FROM tblproduct_in_pharmacy WHERE product_id=" . $data['id'] . " ORDER BY price DESC LIMIT 0,1");
        $myprice1 = mysql_fetch_assoc($price1);
        /* end get price */
        if ($i % 4 == 1) {
            echo '<div class="row-fluid box-product">';
        }
        ?>
        <div class="span3 product_block">
       	   <a href="<?php echo base_url; ?>/product/product_detail.php?product_id=<?php echo $data['id'] ?>">
            <div class="product-inner feature-inner">
                <div class="image">
                    <img src="<?php echo W_S_IMAGES_DIR . $data['images'] ?>">
                </div>
                <div class="wrap-infor"><div class="name">
                      <?php echo $data['product_name'] ?>
                    </div>
                </div>
                <div class="price">Price:
                    <span class="price-old"><?php
                        if ($myprice['price'] == $myprice['regular_price']) {
                            ?>
                            <span class="price-new">$<?php echo $myprice['price']; ?></span>
                            <?php
                        } else {
                            ?>
                            <?php echo $myprice['regular_price']; ?>
                            <?php
                        }
                        ?> </span> <span class="price-new">$<?php echo $myprice['price']; ?></span>
                </div>

            </div>
           </a>
            <span class="label <?php echo ($data[Tblproduct::product_version] == 1) ? '' : 'label-warning'; ?> prodct-type"><?php echo ($data[Tblproduct::product_version] == 1) ? $lang['PRO_STATUS_USED'] : $lang['PRO_STATUS_NEW']; ?></span>
        </div><?php
        if ($i % 4 == 0) {
            echo "</div>";
        }
        $i++;
    }
    if ($i % 4 != 1)
        echo "</div>";
} else {
    ?>
    <div class="row-fluid box-product">
        <div class="twelve columns">
            <div class="bo_eee radius1 ba_fff pad_10" style="margin-right: 15px; margin-bottom:15px;">
                <h3 align="center" style="text-align:center;">No Product in <?php echo @getCategoryName($category_id); ?> </h3>
            </div>
        </div>
    </div>
<?php }; ?>
<div style="text-align: center;"><a class="secondary button" href="<?php echo base_url ?>product/?user=<?php echo $seller_id; ?>">View All Products</a></div>



